package com.kuang.single;

/**
 * Author: Zhang Dongwei
 * Date: 2022/3/16 16:33
 * 饿汉式单例
 * 单例最重要的思想是构造器私有
 */
public class Hungry {

    // 可能会浪费空间
    private byte[] data1 = new byte[1024*1024];
    private byte[] data2 = new byte[1024*1024];
    private byte[] data3 = new byte[1024*1024];
    private byte[] data4 = new byte[1024*1024];

    private Hungry(){

    }
    private final static Hungry HUNGRY = new Hungry(); // 一开始就加载对象

    public static Hungry getInstance(){
        return HUNGRY;
    }
}
